import {getWalletsInfo,getRealNameState,createWalletAccountInfo,toWithdrawal,getBankList,setDefaltBank,cancelBankCar,getWithdrawalRecord,getRealnameInfo} from "../../ajax/module/wallets.js"

export class Wallet{
  constructor(callback,key){
       if(key == 1){
        this._do(callback)
       }else{
        this._selectAccount(callback)
       }
      
  }
  // 是否实名认证
  static _isRealName(callback){
    //  callback(true)
    getRealNameState().then(res=>{
      // console.log(res)
        callback(res.data)
    })   
  }
// 获取实名认证信息
static _getRealNameInfo(callback){
  getRealnameInfo().then(res=>{
     callback(res.data)
  })
}


  // 提现
  static _toWithdrawal(data,callback){
    toWithdrawal(data).then(res=>{
         callback(res)
    })
  }

  // 获取银行卡列表
  static _getBankCard(callback){
    getBankList().then(res=>{
      callback(res.data)
    })
  }

  // 设置默认银行卡
  static _setDefaltBank(data,callback){
    setDefaltBank(data).then(res=>{
      callback(res)
    })
  }
  //解除绑定
  static _cancelBankCar(data,callBack){
    cancelBankCar(data).then(res=>{
      callBack(res)
    })
  }

  // 获取提现记录
  static _getWithdrawalRecord(data,callback){
    getWithdrawalRecord(data).then(res=>{
      callback(res.data)
    })

  }

  

  _do(callback){
    // 申请开通钱包
    createWalletAccountInfo().then(res=>{
      // 获取账户余额信息
      getWalletsInfo().then(res=>{
        let {balance,bounty,coinNum,depositMoney,overdueMoney,walletId}  = res.data
        callback(res)   
      })
    })
    
  }
  _selectAccount(callback){
    getWalletsInfo().then(res=>{
      let {balance,bounty,coinNum,depositMoney,overdueMoney,walletId}  = res.data
      callback(res)   
    })
  }
  
   

}

